<template>
  <div>
    <p>用户名:<input type="text" v-model="username"></p>
    <p>密码:<input type="text" v-model="password"></p>
    <p>确认密码:<input type="text" v-model="password1"></p>
    <p>手机号：<input type="text" v-model="phone"></p>
    <p>头像：<input type="file" id="img"></p>
    <p><button @click="btn">添加</button></p>
  </div>

</template>

<script>
    export default {
        name: "Register",
        data(){
          return{
            username:'',
            password:'',
            password1:'',
            phone:'',
            list:[]
          }
        },
        methods:{
          btn(){
            let img=document.getElementById('img').files[0]
            let formdata=new FormData()
            formdata.append('username',this.username)
            formdata.append('password',this.password)
            formdata.append('password1',this.password1)
            formdata.append('phone',this.phone)
            formdata.append('img',img)
            axios({
              url:'http://127.0.0.1:8000/app01/register/',
              method:'post',
              data:formdata
            }).then(res=>{
              alert(res.data)
            })
          }
        },
    }
</script>

<style scoped>

</style>